package com.lin.filegraph.utils.parser.astutil;

import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.FileASTRequestor;
import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: linhuaixu
 * @time: 2023/5/18 10:35
 */
public class ASTFileASTRequestor extends FileASTRequestor{
    private List<CompileUnit> compileUnits;
    private String projectPath = null;

    public ASTFileASTRequestor() {
        compileUnits = new ArrayList<>();
    }

    @Override
    public void acceptAST(String sourceFilePath, CompilationUnit ast) {
        super.acceptAST(sourceFilePath, ast);
        CompileUnit compileUnit = new CompileUnit(sourceFilePath, ast);
        compileUnits.add(compileUnit);
    }

    public List<CompileUnit> getCompileUnits() {
        return compileUnits;
    }

    public void setCompileUnits(ArrayList<CompileUnit> compileUnits) {
        this.compileUnits = compileUnits;
    }

    public String getProjectPath() {
        return projectPath;
    }
}
